#pragma once
#include "stdafx.h"
#include <termios.h>
#include <pthread.h>
#include "IOnRecv.h"

class Uart
{
public:
	Uart();
	virtual ~Uart();
public:
	bool Open(const char* path, int baud);
	void Close();
	bool IsOpen();
	void SetOnRecv(IOnRecv* pOnRecv);
	int  Write(const unsigned char* pData, int nLength);
private:
	bool BeT();
	static void* Proc(void* lpParam);
	void* Func();
private:
	int    m_fd;
	pthread_t m_Th;
	bool   m_bOpen;
	unsigned char   m_RecvBuf[4000];
	IOnRecv* m_pOnRecv;
};
